package com.hbnu.net;

import java.net.InetAddress;

public class InetAddressDemo {
    public static void main(String[] args) throws Exception {
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost.getHostAddress());         //获取电脑ip地址
        System.out.println(localHost.getHostName());            //获取本机电脑名

        InetAddress remote = InetAddress.getByName("153.3.238.110");        //通过ip地址获取网络主机信息
        System.out.println(remote.getHostName());
    }


}
